package cate.common.table.guild;

import cate.common.table.ESheet;
import easy.java.dev.note.NoteField;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GuildMallItemSheet extends ESheet<GuildMallItemRow> {
    @Override
    public String getSheetName() {
        return "公会宝库商品";
    }


    @NoteField(
            value = "商店商品",
            detail = "Map<商店ID，普通商品列表>")
    private Map<Integer, List<GuildMallItemRow>> mallItemsMap = new HashMap<>();

    @Override
    protected void onRowCreated(GuildMallItemRow row) {
        super.onRowCreated(row);
        if (mallItemsMap.get(row.mallId) == null)
            mallItemsMap.put(row.mallId, new ArrayList<GuildMallItemRow>());
        mallItemsMap.get(row.mallId).add(row);
    }

    /**
     * 获取一个商店的商品列表
     */
    public List<GuildMallItemRow> getMallItemList(int mallId) {
        List<GuildMallItemRow> data = mallItemsMap.get(mallId);
        if (data == null) {
            return new ArrayList<>();
        }
        return data;
    }
}
